#include <iostream>
#include <unordered_map>
#include <cmath>

bool is_prime(int num) {
    if (num < 2)
        return false;
    for (int i = 2; i <= sqrt(num); i++) {
        if (num % i == 0)
            return false;
    }
    return true;
}

int word_to_number(std::string word) {
    std::unordered_map<std::string, std::string> numbers = {{"zero", "0"}, {"one", "1"}, {"two", "2"}, {"three", "3"}, {"four", "4"}, {"five", "5"}, {"six", "6"}, {"seven", "7"}, {"eight", "8"}, {"nine", "9"}};
    return std::stoi(numbers[word]);
}

int main() {
    std::string word1, word2, word3;
    std::cin >> word1 >> word2 >> word3;
    
    int number = word_to_number(word1) * 100 + word_to_number(word2) * 10 + word_to_number(word3);
    
    while (!is_prime(number)) {
        number++;
    }
    
    std::cout << number << std::endl;
    
    return 0;
}